This report is currently based on all regions. We'll modify the selection criteria to include only data from the USA. But first you may need to add a reference to
your project.
This code should appear in the General Declarations section.
Dim Report As New CrystalReport1
This code should appear in the Form_Load event procedure. It tells the viewer what report it should display and then it tells it to display (view) the report.
Screen.MousePointer = vbHourGlass CRViewer1.ReportSource = Report CRViewer1.ViewReport Screen.MousePointer = vbDefault
This code should appear in the Form_Resize event procedure, it resizes the viewer every time the form is resized.
CRViewer1.Top = 0 CRViewer1.Left = 0 CRViewer1.Height = ScaleHeight CRViewer1.Width = ScaleWidth
Dim Report As New CrystalReport1
Screen.MousePointer = vbHourGlass
rs.Open "Select * from customer where country = 'USA'", _"xtreme sample database"
Report.Database.SetDataSource rs,3,1
CRViewer1.ReportSource = Report
Screen.MousePointer = vbDefault
This adds a query to select only the records with "USA" in the "Country" field. The recordset that results from that query will be passed to the report engine and the results displayed.
Private Sub Section5_Format(ByVal pFormattingInfo As Object)
Text5.SetText "Here is some text from my app"
To complete this exercise, you'll now add some event
Private Sub CRViewer1_DrillOnGroup(GroupNameList As
Variant, ByVal DrillType As
CRVIEWERLibCtl.CRDrillType, UseDefault As Boolean)
MsgBox "You're drilling down on the " &
GroupNameList(0) & " group!"
Private Sub CRViewer1_PrintButtonClicked(UseDefault As Boolean)
MsgBox "You clicked the Print button!"
Now that you've seen a few simple ways to modify a report, you may want to explore some of the other properties and events in the report engine that you can use in your application. For more sophisticated programming examples, consult the sample applications. For more details on specific methods, properties, or events, use the VB Object Browser or consult the Crystal Reports Developer's Help (CrystalDevHelp.chm) or the Report Designer Component Help (Crrdc.hlp).
Seagate Software IMG Holdings, Inc. http://www.seagatesoftware.com Support services: http://support.seagatesoftware.com |